/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.webbapps.cormac_susilo.resources;

import edu.webbapps.cormac_susilo.core.IUserModel;
import edu.webbapps.cormac_susilo.wrappers.FrameWrapper;

import java.util.List;
import java.util.NoSuchElementException;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.*;

/**
 * Web Rest Service for Frame
 * 
 * Put,Post,Delete are not managed via REST
 * 
 * @author tor
 */
@RequestScoped
@Path("user/{user_id}/run/{run_id}/frame")
public class FrameResource {
    
    @Inject
    private IUserModel mgr;
        
    @Context
    private UriInfo context;

    @GET
    @Produces("application/json")
    public Response getAll(@PathParam("user_id") long user_id, @PathParam("run_id") long run_id) {
        try {
            List<FrameWrapper> frames = mgr.getFrames(run_id);
            GenericEntity<List<FrameWrapper>> ge = new GenericEntity<List<FrameWrapper>>(frames) {};
            return Response.ok(ge).build();
            
        } catch (NoSuchElementException e) {
            return Response.noContent().build();
        }
    }
}
